#!/usr/bin/env python


def center_screen(root, width, height):
    screenwidth = root.winfo_screenwidth()
    screenheight = root.winfo_screenheight()
    size = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
    return size


def center_dialog(root, width, height):
    root_size, x, y = root.geometry().split('+')
    root_x, root_y = root_size.split('x')
    size = f'{width}x{height}+{int((int(root_x) - width) / 2 + int(x))}+{int((int(root_y) - height) / 2 + int(y))}'
    return size
